package com.txw.travel.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.txw.travel.mapper.ProductMapper;
import com.txw.travel.pojo.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional//add tran
public class ProductService {

    @Autowired
    private ProductMapper productMapper;

    public Page<Product> getProductPage(Integer index, Integer size) {
        return productMapper.getProductPage(new Page<Product>(index, size));
    }

    public Product getProductById(Integer pid) {
        return productMapper.selectById(pid);
    }

    public void insertProduct(Product product) {
        productMapper.insert(product);
    }

    public void updateProduct(Product product) {
        productMapper.updateById(product);
    }

    public void deleteProduct(Integer pid) {
        productMapper.deleteById(pid);
    }
}
